<?php
    class Users_model extends CI_Model {
        
        function __construct() {
            parent::__construct();
        }
        
        function get_last_ten_entries() {
            $this->db->order_by('users_id', 'desc');
            $query = $this->db->get('users', 20);
            return $query->result_array();
        }
        
        function insert_one_entrie($data) {
            $this->db->insert('users', $data);
        }
        
        function drop_one_entrie($id) {
            $this->db->where('users_id', $id);
            $this->db->delete('users');
        }
        
        function isset_login($login) {
            $query = $this->db->get_where('users', array('users_login' => $login));
            $result = $query->result_array();
            if ($result)
                return true;
            else
                return false;
        }
        
        function get_one_entrie($id) {
            $this->db->where('users_id', $id);
            $query = $this->db->get('users');
            return $query->result_array();
        }
        
        function update_one_entrie($id, $data) {
            $this->db->where('users_id', $id);
            $this->db->update('users', $data);
        }
    }
?>
